package pers.mihao.quickstream.publish.strategy.context;

import lombok.Getter;
import pers.mihao.quickstream.account.model.vo.Account;
import pers.mihao.quickstream.account.service.AccountService;
import pers.mihao.quickstream.common.util.spring.SpringUtil;
import pers.mihao.quickstream.material.model.dto.VideoMaterialDTO;
import pers.mihao.quickstream.material.model.vo.VideoMaterial;
import pers.mihao.quickstream.material.service.VideoMaterialService;
import pers.mihao.quickstream.publish.model.dto.PublishTaskDTO;

import java.util.HashMap;
import java.util.Map;

/**
 * @author mihao
 * @since 2024/11/24
 */
public class ChooseContext {

    @Getter
    private final Long opUserId;

    @Getter
    private final PublishTaskDTO publishTaskDTO;

    private VideoMaterial videoMaterial;

    public ChooseContext(PublishTaskDTO publishTaskDTO) {
        this.publishTaskDTO = publishTaskDTO;
        this.opUserId = publishTaskDTO.getOpUserId();
    }

    public VideoMaterial getVideoMaterial() {
        if (videoMaterial == null) {
            videoMaterial = videoMaterialService().queryByVideoMaterialId(publishTaskDTO.getMaterialId());
        }
        return videoMaterial;
    }

    private final Map<Long, Account> accountMap = new HashMap<>();

    public Account getAccount(Long accountId) {
        Account account = accountService().queryAccountById(accountId);
        return null;
    }

    private AccountService accountService() {
        return SpringUtil.getBean(AccountService.class);
    }

    private VideoMaterialService videoMaterialService() {
        return SpringUtil.getBean(VideoMaterialService.class);
    }


}
